// 关于甄成动画
function initAboutIntro() {
    // 检查是否存在关于甄成相关元素
    const aboutSection = document.querySelector('.about-section');
    if (!aboutSection) {
        console.log('About intro element not found, skipping animation initialization');
        return;
    }

    console.log('About intro animation initialized');

    const aboutImage = document.querySelector('.about-image');
    const aboutText = document.querySelector('.about-text');

    // 初始化动画
    function initAnimations() {
        // 设置初始状态
        aboutImage.style.opacity = '0';
        aboutImage.style.transform = 'translateX(-20px)';
        aboutText.style.opacity = '0';
        aboutText.style.transform = 'translateX(20px)';
    }

    // 执行动画
    function animateElements() {
        // 图片动画
        aboutImage.style.transition = 'all 0.8s ease-out';
        aboutImage.style.opacity = '1';
        aboutImage.style.transform = 'translateX(0)';

        // 文字动画
        setTimeout(() => {
            aboutText.style.transition = 'all 0.8s ease-out';
            aboutText.style.opacity = '1';
            aboutText.style.transform = 'translateX(0)';
        }, 200);
    }

    // 检查元素是否在视口中
    function isInViewport(element) {
        const rect = element.getBoundingClientRect();
        return (
            rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
            rect.bottom >= 0
        );
    }

    // 监听滚动事件
    function handleScroll() {
        if (isInViewport(aboutSection)) {
            animateElements();
            window.removeEventListener('scroll', handleScroll);
        }
    }

    // 初始化
    initAnimations();
    window.addEventListener('scroll', handleScroll);
    // 立即检查一次，以防元素已经在视口中
    handleScroll();
}

// 确保在组件加载完成后执行
if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', initAboutIntro);
} else {
    initAboutIntro();
} 